SUBROUTINE TABLE_S5
* Create a table organised into horizontal and vertical sections.* This demonstrates the use of most of the table functions.* Include the RealWeb definitions.
INCLUDE #RW.INCLUDE.DEFS FROM /SYSFILES/REALWEB,BP
EQU LF TO CHAR(10)
EQU TAB TO CHAR(9)
EQU AM TO CHAR(254)
EQU VM TO CHAR(253)
* Get the URL of the Reality item server.
STYLESHEET = ""
CALL RW_GET_PARAM("__isurl", STYLESHEET)* Specify the location of the stylesheet.
STYLESHEET = STYLESHEET : "/REALWEB-ITEMS/blue.css"
* Start the HTML page.CALL RW_START_HTML_PAGE("Complex RWS_Table Example", "", STYLESHEET, "", "")* Create a caption to appear below the table.
TABLE = "Cereal preference, by Gender"
aClass = ""
aClass<2> = "bottom"
CALL RWS_TABLE_CAPTION(TABLE, aClass)* Create groups of columns.CALL RWA_TABLE_COLGROUP(TABLE, 1, "", "")CALL RWA_TABLE_COLGROUP(TABLE, 1, "", "")CALL RWA_TABLE_COLGROUP(TABLE, 2, "", "")* Build up the data to go in the table, by adding the cells to a* row one at a time. When complete, add the row to the section.* When the section is complete, add it to the table.* Start with a head section containing two rows.* The top left-hand corner of the table will contain an empty cell* spanning two columns and two rows.
CELL = ""
aClass = ""
aClass<4> = 2 ;* Span two columns.
aClass<5> = 2 ;* Span two rows.CALL RWS_TABLE_HEADER(CELL, aClass) ;* Create the cell.
ROW = CELL ;* Add it to the row.* The next cell will span two columns of the top row.
CELL = "Cereal"
aClass = ""
aClass<4> = 2 ;* Span two columns.CALL RWS_TABLE_HEADER(CELL, aClass) ;* Create the cell.
ROW = ROW : CELL ;* Add it to the row.CALL RWS_TABLE_ROW(ROW, "") ;* Create the table row.
SECT = ROW ;* Add it to the head section.* The second row will contain two header cells.
CELL = "Choco flakes"
CALL RWS_TABLE_HEADER(CELL, "")
ROW = CELL
CELL = "Bran rings"
CALL RWS_TABLE_HEADER(CELL, "")
ROW = ROW : CELL ;* Add them to the row.CALL RWS_TABLE_ROW(ROW, "") ;* Create the table row.
SECT = SECT : ROW ;* Add it to the head section.CALL RWS_TABLE_HEAD(SECT, "") ;* Create the head section.
TABLE = TABLE : SECT ;* Add it to the table.* The body of the table will be divided into to two sections, each* containing two rows.* The first cell will span two rows.
CELL = "Boys"
aClass = ""
aClass<5> = 2 ;* Span two rows.CALL RWS_TABLE_HEADER(CELL, aClass)
ROW = CELL : LF
* The rest of the row will contain a header and two data cells.
CELL = "Under 11"
CALL RWS_TABLE_HEADER(CELL, "")
ROW = ROW : CELL : LF
CELL = "92%"
CALL RWS_TABLE_DATA(CELL, "")
ROW = ROW : CELL : LF
CELL = "8%"
CALL RWS_TABLE_DATA(CELL, "")
ROW = ROW : CELL
CALL RWS_TABLE_ROW(ROW, AM:"CENTER") ;* Create the table row.
SECT = ROW ;* Add it to the body section.* The second row will also contain a header and two data cells.
CELL = "11 and over"
CALL RWS_TABLE_HEADER(CELL, "")
ROW = CELL : LF
CELL = "87%"
CALL RWS_TABLE_DATA(CELL, "")
ROW = ROW : CELL : LF
CELL = "13%"
CALL RWS_TABLE_DATA(CELL, "")
ROW = ROW : CELL : LF
CALL RWS_TABLE_ROW(ROW, AM:"CENTER") ;* Create the table row.
SECT = SECT : ROW : LF ;* Add it to the body section.CALL RWS_TABLE_BODY(SECT, "") ;* Create the body section.
TABLE = TABLE : SECT : LF ;* Add it to the table.* The second body section will have the same structure as the first.
CELL = "Girls"
aClass = ""
aClass<5> = 2 ;* Span two rows.CALL RWS_TABLE_HEADER(CELL, aClass)
ROW = CELL : LF
CELL = "Under 11"
CALL RWS_TABLE_HEADER(CELL, "")
ROW = ROW : CELL : LF
CELL = "74%"
CALL RWS_TABLE_DATA(CELL, "")
ROW = ROW : CELL : LF
CELL = "26%"
CALL RWS_TABLE_DATA(CELL, "")
ROW = ROW : CELL
CALL RWS_TABLE_ROW(ROW, AM:"CENTER") ;* Create the table row.
SECT = ROW : LF ;* Add it to the body section.
CELL = "11 and over"
CALL RWS_TABLE_HEADER(CELL, "")
ROW = CELL : LF
CELL = "37%"
CALL RWS_TABLE_DATA(CELL, "")
ROW = ROW : CELL : LF
CELL = "63%"
CALL RWS_TABLE_DATA(CELL, "")
ROW = ROW : CELL
CALL RWS_TABLE_ROW(ROW, AM:"CENTER") ;* Create the table row.
SECT = SECT : ROW : LF ;* Add it to the body section.CALL RWS_TABLE_BODY(SECT, "") ;* Create the body section.
TABLE = TABLE : SECT : LF ;* Add it to the table.* The foot section will contain a single row containing one cell* centred across all four columns.
CELL = "Excludes children under 5."
aClass = ""
aClass<2> = "CENTER" ;* Centre the text.
aClass<4> = 4 ;* Span four columns.CALL RWS_TABLE_DATA(CELL, aClass)CALL RWS_TABLE_ROW(CELL, "") ;* Create the table row.CALL RWS_TABLE_FOOT(CELL, "") ;* Create the foot section.
TABLE = TABLE : CELL : LF ;* Add it to the table.* Give the table a border.
aClass = ""
aClass<2> = "border"
* Draw rules between the sections.
aClass<3> = "GROUPS"
* Set the cell spacing and padding.* Give the table a background colour.
aClass<4> = "cellspacing=0 cellpadding=5 bgcolor=lightsteelblue"
* Create the table.CALL RWS_TABLE(TABLE, aClass)* Output the TABLE.CALL RW_PUT(TABLE)* Complete the page.CALL RW_END_PAGE
RETURN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><HTML><HEAD><META NAME="Generator" CONTENT="Reality"><TITLE>Complex RWS_Table Example</TITLE><STYLE type="text/css"><!-- @import url(/servlet/realityis/test/REALWEB-ITEMS/blue.css); --></STYLE></HEAD><BODY><TABLE BORDER="border" RULES="GROUPS" cellspacing=0 cellpadding=5 bgcolor=lightsteelblue><CAPTION ALIGN="bottom">Cereal preference, by Gender</CAPTION><COLGROUP SPAN="1"><COLGROUP SPAN="1"><COLGROUP SPAN="2"><THEAD><TR><TH COLSPAN="2" ROWSPAN="2"></TH><TH COLSPAN="2">Cereal</TH></TR><TR><TH>Choco flakes</TH><TH>Bran rings</TH></TR></THEAD><TBODY><TR ALIGN="CENTER"><TH ROWSPAN="2">Boys</TH><TH>Under 11</TH><TD>
92%
</TD><TD>
8%
</TD></TR><TR ALIGN="CENTER"><TH>11 and over</TH><TD>
87%
</TD><TD>
13%
</TD></TR></TBODY><TBODY><TR ALIGN="CENTER"><TH ROWSPAN="2">Girls</TH><TH>Under 11</TH><TD>
74%
</TD><TD>
26%
</TD></TR><TR ALIGN="CENTER"><TH>11 and over</TH><TD>
37%
</TD><TD>
63%
</TD></TR></TBODY><TFOOT><TR><TD ALIGN="CENTER" COLSPAN="4">
Excludes children under 5.
</TD></TR></TFOOT></TABLE></BODY></HTML>